package com.zgjkhis.modules.system.service.mapper;

import com.zgjkhis.common.mapper.CoreMapper;
import com.zgjkhis.modules.system.domain.Message;
import com.zgjkhis.modules.system.service.dto.MessageQueryCriteria;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author yzq
 * @Description 消息通知
 * @Date 2021/6/23 9:48
 * @Param
 * @return
 **/
@Repository
public interface MessageMapper extends CoreMapper<Message> {


    /**
     * 查看所有消息
     * @param criteria
     * @return
     */
    @Select("<script>select * from his_message t where t.is_delete=0 and t.pharmacy_id =#{message.pharmacyId}" +
            "<if test=\"message.isLook !=null and message.isLook != ''\">\n" +
            "\t and t.is_look = #{message.isLook}\n" +
            "</if>\n" +
            " </script>")
    List<Message> queryAll(@Param("message") MessageQueryCriteria criteria);

    /**
     * 查看所有消息个数
     * @param criteria
     * @return
     */
    @Select("<script>select count(1) from his_message t where t.is_delete=0 and t.pharmacy_id =#{message.pharmacyId}" +
            "<if test=\"message.isLook !=null and message.isLook != ''\">\n" +
            "\t and t.is_look = #{message.isLook}\n" +
            "</if>\n" +
            " </script>")
    Integer count(@Param("message") MessageQueryCriteria criteria);
}
